export const withSignal = (func, extCancelFunc) => {
  if (typeof func !== 'function') throw '传入的func不是函数'
  if (extCancelFunc && typeof extCancelFunc !== 'function') throw '传入的extCancelFunc不是函数'

  let controller = new AbortController()
  func(controller.signal)

  return () => {
    controller.abort()
    extCancelFunc && controller.abort()
  }
}